$(function() {
	
	loadData();
	
});

function loadData() {
	initOneSubject();
	initTwoSubject();
	initThreeSubject();
	initFourSubject();
}

function commonAjaxData(){
	var result = '';
	$.ajax({
		type: 'GET',
		data: jsonData,
	    url: url,
	    async: false,
	    dataType:"json",
	    success: function(data){
	    	result = data;
	    },
	    error: function(){
	    }
	});
	return result;
}



function initOneSubject() {
	
	//url = ctx + '/show/degree';
	//jsonData = '';	//jsonData = {startTime:startTime,endTime:endTime};
	//var  returnData= commonAjax();
	//"高等数学2","大学体育","毛泽东思想概论",
	var data = [{name:"易云",score:"95",width:"99",subject:"马克思主义哲学"},
	            {name:"张三",score:"75",width:"89",subject:"马克思主义哲学"},
	            {name:"赵娜",score:"80",width:"94",subject:"马克思主义哲学"},
	            {name:"张恒",score:"79",width:"78",subject:"马克思主义哲学"},
	            {name:"涂新",score:"90",width:"85",subject:"马克思主义哲学"},
	            ];



	var tbodyHtml = initOneSubjectHtml(data);
	
	$('#OneSubject_tbody').html(tbodyHtml);
}

function initTwoSubject() {
	
	//url = ctx + '/show/degree';
	//jsonData = '';	//jsonData = {startTime:startTime,endTime:endTime};
	//var  returnData= commonAjax();
	//"","大学体育","毛泽东思想概论",
	var data = [{name:"赵宾宾",score:"95",width:"79",subject:"高等数学2"},
	            {name:"钱峰",score:"75",width:"89",subject:"高等数学2"},
	            {name:"孙芸芸",score:"80",width:"90",subject:"高等数学2"},
	            {name:"李易",score:"79",width:"78",subject:"高等数学2"},
	            {name:"张开",score:"90",width:"85",subject:"高等数学2"},
	            ];



	var tbodyHtml = initOneSubjectHtml(data);
	
	$('#TwoSubject_tbody').html(tbodyHtml);
}

function initThreeSubject() {
	
	//url = ctx + '/show/degree';
	//jsonData = '';	//jsonData = {startTime:startTime,endTime:endTime};
	//var  returnData= commonAjax();
	//"高等数学2","大学体育","毛泽东思想概论",
	var data = [{name:"郑春新",score:"95",width:"99",subject:"大学体育"},
	            {name:"王文",score:"75",width:"89",subject:"大学体育"},
	            {name:"佟卫国",score:"90",width:"85",subject:"大学体育"},
	            ];



	var tbodyHtml = initOneSubjectHtml(data);
	
	$('#ThreeSubject_tbody').html(tbodyHtml);
}

function initFourSubject() {
	
	//url = ctx + '/show/degree';
	//jsonData = '';	//jsonData = {startTime:startTime,endTime:endTime};
	//var  returnData= commonAjax();
	//"高等数学2","大学体育","毛泽东思想概论",
	var data = [{name:"吴三省",score:"95",width:"89",subject:"毛泽东思想概论"},
	            {name:"张辽",score:"75",width:"89",subject:"毛泽东思想概论"},
	            {name:"赵括",score:"80",width:"94",subject:"毛泽东思想概论"},
	            {name:"新信",score:"90",width:"85",subject:"毛泽东思想概论"},
	            ];



	var tbodyHtml = initOneSubjectHtml(data);
	
	$('#FourSubject_tbody').html(tbodyHtml);
}

function initOneSubjectHtml(data){
	var returnHtml = '';
	
	if (data.length == 0)
		returnHtml = '<tr><td colspan="5">暂无数据</td></tr>';
	else
		$.each(data, function(index, item) {
			returnHtml += "<tr>"
		            + "<td class='project-status'>"
		            + "<span class='label label-primary'>成绩</td>"    
		            + "<td class='project-title'>"
		            + "<a href='#'>"+item.subject+"</a> <br/>"
		            + "<small>时间 2017.06.15</small></td>"
		            + "<td class='project-completion'>"
		            + "<small>试卷完成度："+item.width+"%</small>"
		            + "<div class='progress progress-mini'>"
		            + "<div style='width: "+item.width+"%;' class='progress-bar'></div></div> </td>"
                    + " <td class='project-people'>"
                    + " <a href='#'>姓名："+item.name+"</a>"
                    + "</td>"
                    + " <td class='project-people'>"
                    + " <a href='#'>成绩："+item.score+"</a>"
                    + "</td>"
                    + "<td class='project-actions'>"
                    + "<a href='/paperShow' class='btn btn-white btn-sm'><i class='fa fa-folder'></i> 查看 </a>"
                    + "</td></tr>";
            
		});

	
	return returnHtml;
}